import 'package:im_app/im/pojo/ImPojo.dart';

class DepartmentTreeNode {
  final ImDepartment? department;
  final ImUser? user;
  final bool isMore;
  final List<DepartmentTreeNode> children;

  DepartmentTreeNode({ImDepartment? department, ImUser? user, bool? isMore, List<DepartmentTreeNode>? children}) :
        this.department = department,
        this.user = user,
        this.isMore = isMore??false,
        this.children = children??<DepartmentTreeNode>[]
  ;

  DepartmentTreeNode.moreData() : this(isMore: true);

  static List<DepartmentTreeNode> buildChildren(List<ImDepartment> departments) {
    List<DepartmentTreeNode> result = <DepartmentTreeNode>[];
    for (var department in departments) {
      var treeNode = DepartmentTreeNode(department: department);
      result.add(treeNode);
    }
    return result;
  }
}